package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.dto.app.DisplayUserVocBoundLogDTO;
import com.cskaoyan.wordmemorize.dto.app.UserVocBoundStatisticsDTO;
import com.cskaoyan.wordmemorize.request.PageRequest;
import com.cskaoyan.wordmemorize.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/voc/bound")
public class UserVocBoundController {

    @Autowired
    UserService userService;

    @GetMapping("/detail")
    public Result<PageDTO<DisplayUserVocBoundLogDTO>> getUserVocBoundLog(PageRequest pageRequest) {
        Long userId = StpKit.USER.getLoginIdAsLong();
        PageDTO<DisplayUserVocBoundLogDTO> userVocBoundLog = userService.getUserVocBoundLog(pageRequest, userId);
        return Result.ok(userVocBoundLog);
    }

    @GetMapping("/statistics")
    public Result getUserVocBoundStatistics() {
        Long userId = StpKit.USER.getLoginIdAsLong();
        UserVocBoundStatisticsDTO userVocBoundStatistics = userService.getUserVocBoundStatistics(userId);
        System.out.println(userId);
        return Result.ok(userVocBoundStatistics);
    }
}